﻿Public Class frmConexaoBD

#Region "Variáveis"

    Private objAcesso As New ControlePadrao.ctrAcessoBD()

#End Region

#Region "Propriedades"

    Public Property conexaoRealizada As Boolean

#End Region

#Region "Eventos"

    Private Sub btnTestarConexao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestarConexao.Click

        Try

            If objAcesso.testarConexao(objAcesso.montaStringConexao(Me.txtSenha.Text, Me.txtBD.Text, Me.txtServidor.Text, Me.txtLogin.Text)) Then
                MessageBox.Show("Conexão estabelecida com sucesso.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("Não foi possível estabelecer a conexão.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Try

            If objAcesso.testarConexao(objAcesso.montaStringConexao(Me.txtSenha.Text, Me.txtBD.Text, Me.txtServidor.Text, Me.txtLogin.Text)) Then
                Me.conexaoRealizada = True
                objAcesso.salvarArquivoConexao(Me.txtSenha.Text, Me.txtBD.Text, Me.txtServidor.Text, Me.txtLogin.Text)

                Me.Close()

            Else
                Me.conexaoRealizada = False
                MessageBox.Show("Não foi possível estabelecer a conexão.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

    Private Sub btnSair_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSair.Click
        Me.conexaoRealizada = False
        Me.Close()

    End Sub

#End Region


End Class